package cn.bgs.service.impl;

import cn.bgs.mapper.BillMapper;
import cn.bgs.page.PageRequest;
import cn.bgs.pojo.TopUp;
import cn.bgs.pojo.User;
import cn.bgs.service.BillService;
import cn.bgs.utils.R;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.w3c.dom.stylesheets.LinkStyle;

import java.util.List;

@Service
public class BillServiceImpl implements BillService {
    @Autowired
    private BillMapper billMapper;

    @Override
    public PageInfo<TopUp> billSelect(PageRequest pageRequest, String userName) {
        PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getPageSize());
        PageInfo<TopUp> userPageInfo = new PageInfo<>(billMapper.selectAll(userName));
        return userPageInfo;
    }

    @Override
    public R userNameSelect() {
        List<User> list = billMapper.userNameSelect();
        return R.ok().data("list",list);
    }

    @Override
    public R billDelete(Integer topUpId) {
        int i = billMapper.billDelete(topUpId);
        return R.ok().data("i",i);
    }

    @Override
    public R billAdd(TopUp topUp) {
        int i = billMapper.billAdd(topUp);
        return R.ok().data("i",i);
    }

    @Override
    public R billUpdate(TopUp topUp) {
        int i = billMapper.billUpdate(topUp);
        return R.ok().data("i",i);
    }


}
